"""Definition of the secondhandinfo content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtinfocontent import xtinfocontentMessageFactory as _

from my315ok.xtinfocontent.interfaces import Isecondhandinfo
from my315ok.xtinfocontent.config import PROJECTNAME

secondhandinfoSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

   

    atapi.DateTimeField(
        'registereddatetime',
        storage=atapi.AnnotationStorage(),
        widget=atapi.CalendarWidget(
            label=_(u"registered date"),
            description=_(u""),
        ),
        validators=('isValidDate'),
    ),

#
#    atapi.DateTimeField(
#        'effectivedate',
#        storage=atapi.AnnotationStorage(),
#        widget=atapi.CalendarWidget(
#            label=_(u"effectivedate"),
#            description=_(u""),
#        ),
#        validators=('isValidDate'),
#    ),


    atapi.TextField(
        'text',
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.RichWidget(
            label=_(u"detail description"),
            description=_(u""),
        ),
    ),


    atapi.ImageField(
        'photo',
        storage=atapi.AnnotationStorage(),
        widget=atapi.ImageWidget(
            label=_(u"photo"),
            description=_(u""),
        ),
        validators=('isNonEmptyFile'),
    ),


    atapi.StringField(
        'addr',
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"address"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'phone',
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"phone number"),
            description=_(u""),
        ),
    ),


    atapi.IntegerField(
        'qq',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"qq number"),
            description=_(u""),
            size=30,
        ),
        validators=('isInt'),
        
    ),


    atapi.StringField(
        'author',
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"author"),
            description=_(u""),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

secondhandinfoSchema['title'].storage = atapi.AnnotationStorage()
secondhandinfoSchema['description'].storage = atapi.AnnotationStorage()
secondhandinfoSchema['title'].widget.label = _(u"title")
secondhandinfoSchema['effectiveDate'].schemata = "default"

schemata.finalizeATCTSchema(secondhandinfoSchema, moveDiscussion=False)


class secondhandinfo(base.ATCTContent):
    """a second hand infomation type"""
    implements(Isecondhandinfo)

    meta_type = "secondhandinfo"
    schema = secondhandinfoSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
   

    registereddatetime = atapi.ATFieldProperty('registereddatetime')

    effectivedate = atapi.ATFieldProperty('effectivedate')

    text = atapi.ATFieldProperty('text')

    photo = atapi.ATFieldProperty('photo')

    addr = atapi.ATFieldProperty('addr')

    phone = atapi.ATFieldProperty('phone')

    qq = atapi.ATFieldProperty('qq')

    author = atapi.ATFieldProperty('author')


atapi.registerType(secondhandinfo, PROJECTNAME)
